function ArryCom() {}
ArryCom.prototype.set = function(arry, key, value) {
  if (arry !== undefined && arry.length > 0) {
    arry.forEach(function(datarow) {
      if (datarow[key] !== undefined) {
        datarow[key] = value
      }
    })
  }
}
ArryCom.prototype.get = function(arry, key) {
  if (arry !== undefined && arry.length > 0) {
    const newlist = []
    arry.forEach(function(datarow) {
      if (datarow[key] !== undefined) {
        newlist.push(datarow[key])
      }
    })
    return newlist
  }
  return []
}
ArryCom.prototype.max = function(arry, key) {
  if (arry !== undefined && arry.length > 0) {
    let min = 0
    arry.forEach(function(datarow) {
      if (datarow[key] !== undefined) {
        if (!(min > datarow[key])) {
          min = datarow[key]
        }
      }
    })
    return min
  }
}
ArryCom.prototype.min = function(arry, key) {
  if (arry !== undefined && arry.length > 0) {
    let min = 0
    arry.forEach(function(datarow) {
      if (datarow[key] !== undefined) {
        if (min > datarow[key]) {
          min = datarow[key]
        }
      }
    })
    return min
  }
}
ArryCom.prototype.sum = function(arry, key) {
  if (arry !== undefined && arry.length > 0) {
    let sum = 0
    arry.forEach(function(datarow) {
      if (datarow[key] !== undefined) {
        sum = sum + datarow[key]
      }
    })
    return sum
  }
  return 0
}
ArryCom.prototype.avg = function(arry, key) {
  if (this.length == 0) {
    return 0
  }
  return sumArray(arry, key) / this.length
}
ArryCom.prototype.distinct = function(arry) {
  const newlist = []
  const dicdataobj = []
  function removeRepeatFun(datarow, arguments) {
    let keyvalues = ''
    arguments.forEach(ee => {
      keyvalues = keyvalues + datarow[ee]
    })
    return keyvalues
  }
  arry.forEach(ee => {
    const keyvalues = removeRepeatFun(ee, arguments)
    if (dicdataobj.indexOf(keyvalues) < 0) {
      newlist.push(ee)
    }
  })
  return newlist
}
ArryCom.prototype.sort = function(array, key) {
  return array.sort(function(a, b) {
    const x = a[key]
    const y = b[key]
    return x < y ? -1 : x < y ? 1 : 0
  })
}
ArryCom.prototype.sortdesc = function(array, key) {
  return array.sort(function(a, b) {
    const x = a[key]
    const y = b[key]
    return !(x < y) ? -1 : !(x < y) ? 1 : 0
  })
}
ArryCom.prototype.join = function(array, key, str) {
  return this.get(array, key).json(str)
}
const arrycom = new ArryCom()
